VERSION 5.00
Begin VB.Form colorselector 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Color Selector"
   ClientHeight    =   10695
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   11175
   Icon            =   "colorselector.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   10695
   ScaleWidth      =   11175
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.OptionButton mousemove 
      Caption         =   "Mouse is Moving"
      Height          =   255
      Left            =   3600
      TabIndex        =   11
      Top             =   2760
      Width           =   1575
   End
   Begin VB.OptionButton mouseclick 
      Caption         =   "Mouse is Clicked"
      Height          =   255
      Left            =   1680
      TabIndex        =   10
      Top             =   2760
      Value           =   -1  'True
      Width           =   1575
   End
   Begin VB.PictureBox thepic 
      AutoRedraw      =   -1  'True
      Height          =   6735
      Left            =   120
      MousePointer    =   2  'Cross
      ScaleHeight     =   6675
      ScaleWidth      =   10875
      TabIndex        =   7
      Top             =   3120
      Width           =   10935
      Begin VB.Line vertical 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   3
         X1              =   5400
         X2              =   5400
         Y1              =   0
         Y2              =   6840
      End
      Begin VB.Line horizontal 
         BorderColor     =   &H0000FF00&
         BorderWidth     =   3
         X1              =   0
         X2              =   10920
         Y1              =   3240
         Y2              =   3240
      End
   End
   Begin VB.PictureBox preview 
      Height          =   615
      Left            =   120
      ScaleHeight     =   555
      ScaleWidth      =   10755
      TabIndex        =   6
      Top             =   600
      Width           =   10815
   End
   Begin VB.HScrollBar colorscroll 
      Height          =   255
      Index           =   2
      Left            =   1080
      Max             =   255
      TabIndex        =   5
      Top             =   2400
      Width           =   9855
   End
   Begin VB.HScrollBar colorscroll 
      Height          =   255
      Index           =   1
      Left            =   1080
      Max             =   255
      TabIndex        =   4
      Top             =   1920
      Width           =   9855
   End
   Begin VB.PictureBox blue 
      Height          =   255
      Left            =   120
      ScaleHeight     =   195
      ScaleWidth      =   675
      TabIndex        =   3
      Top             =   2400
      Width           =   735
   End
   Begin VB.PictureBox green 
      Height          =   255
      Left            =   120
      ScaleHeight     =   195
      ScaleWidth      =   675
      TabIndex        =   2
      Top             =   1920
      Width           =   735
   End
   Begin VB.PictureBox red 
      Height          =   255
      Left            =   120
      ScaleHeight     =   195
      ScaleWidth      =   675
      TabIndex        =   1
      Top             =   1440
      Width           =   735
   End
   Begin VB.HScrollBar colorscroll 
      Height          =   255
      Index           =   0
      Left            =   1080
      Max             =   255
      TabIndex        =   0
      Top             =   1440
      Width           =   9855
   End
   Begin Pic2Ascii.CandyButton ok 
      Height          =   495
      Left            =   5040
      TabIndex        =   13
      Top             =   10080
      Width           =   1095
      _ExtentX        =   1931
      _ExtentY        =   873
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "OK"
      IconHighLiteColor=   0
      CaptionHighLiteColor=   0
      Style           =   6
      Checked         =   0   'False
      ColorButtonHover=   14704640
      ColorButtonUp   =   13668448
      ColorButtonDown =   11108432
      BorderBrightness=   0
      ColorBright     =   16775930
      DisplayHand     =   0   'False
      ColorScheme     =   2
   End
   Begin VB.Label position 
      BackStyle       =   0  'Transparent
      Height          =   255
      Left            =   5400
      TabIndex        =   12
      Top             =   2760
      Width           =   1455
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Get color when. . ."
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   2760
      Width           =   1455
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "You can make the color with the scroll bars or select the color from the picture below."
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   120
      Width           =   6135
   End
End
Attribute VB_Name = "colorselector"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub colorscroll_Change(Index As Integer)
Call colorscroll_Scroll(Index)
End Sub

Private Sub colorscroll_Scroll(Index As Integer)
Select Case Index
Case 0
    red.BackColor = rgb(colorscroll(0).Value, 0, 0)
Case 1
    green.BackColor = rgb(0, colorscroll(1).Value, 0)
Case 2
    blue.BackColor = rgb(0, 0, colorscroll(2).Value)
End Select
preview.BackColor = rgb(colorscroll(0).Value, colorscroll(1).Value, colorscroll(2).Value)
End Sub

Private Sub Form_Load()
thepic.Picture = main.thepic.Image
thepic.Height = main.thepic.Height
thepic.Width = main.thepic.Width
End Sub

Private Sub ok_Click()
frmthresholds.colorbox.BackColor = preview.BackColor
Unload Me
End Sub

Private Sub thepic_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then ok_Click
End Sub

Private Sub thepic_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If mouseclick Then GetRGB X, Y
End Sub

Private Sub thepic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If mousemove Then GetRGB X, Y
horizontal.Y1 = Y: horizontal.Y2 = Y
vertical.X1 = X: vertical.X2 = X
position.Caption = X & ", " & Y
End Sub

Private Sub GetRGB(X As Single, Y As Single)
Dim pixelcolor As Double
Dim r, g, b, i As Integer

pixelcolor = thepic.Point(X, Y)

r = &HFF& And pixelcolor
g = (&HFF00& And pixelcolor) \ 256
b = (&HFF0000 And pixelcolor) \ 65536

colorscroll(0).Value = r
colorscroll(1).Value = g
colorscroll(2).Value = b

For i = 0 To 2
    colorscroll_Scroll (i)
Next i
End Sub
